home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F26408_StatesElemToAttr.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  1.0 KB  |  31 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       XMLtoXML
  4.   Sub-category:   ElemToAttr
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylsheet will convert an xml file that is
  10.     element-based to one that is attribute-based.  In this
  11.     stylesheet, the original state elements will be transformed
  12.     to attributes.
  13. ================================================================ -->
  14. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="xml"/>
  15.  
  16. <xsl:template match="/">
  17.     <xsl:element name="data">
  18.         <xsl:for-each select="/data/RECORD" >     
  19.             <xsl:element name='{name()}'> 
  20.                 <xsl:for-each select="*" > 
  21.                     <xsl:attribute name='{name()}'> <xsl:value-of select="."/>
  22.                 </xsl:attribute>
  23.         </xsl:for-each> 
  24.     </xsl:element>
  25.     </xsl:for-each>
  26. </xsl:element>
  27.  
  28. </xsl:template>
  29.  
  30.  
  31. </xsl:stylesheet>